package com.yu.interceptor;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONArray;

import org.apache.log4j.Logger;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class LogInterceptor implements Interceptor {

	private static Logger logger = Logger.getLogger(LogInterceptor.class);
	
    public void intercept(Invocation inv) {
        Controller controller = inv.getController();
        HttpServletRequest request = controller.getRequest();
        Map<String,String[]> map =	request.getParameterMap();
        System.out.println(JSONArray.fromObject(map).toString());
        logger.info(JSONArray.fromObject(map).toString());
        logger.error(JSONArray.fromObject(map).toString());        
        inv.invoke();
    }

}
